import {mutable} from "./types.ts";
import {buildProps} from "@/components/Message/props.ts";

export const messageDefaults = mutable({
    customClass: '',
    center: false,
    dangerouslyUseHTMLString: false, // 传入 message 的内容是否会被当做 HTML 字符串来进行解析和渲染
    duration: 3000,
    icon: undefined,
    id: '',
    message: '',
    onClose: undefined,
    showClose: false,
    type: 'info',
    plain: false,
    offset: 16,
    zIndex: 0,
    grouping: false,
    repeatNum: 1,
    appendTo: document.body,
} as const)

/**
 * @desc message is props
 */
export const messageProps = buildProps({
    // 自定义的类样式
    customClass: {
        type: String,
        default: messageDefaults.customClass
    },
    // 文章是否居中
    center: {
      type: Boolean,
      default: messageDefaults.center,
    },
    dangerouslyUseHTMLString: {
        type: Boolean,
        default: messageDefaults.dangerouslyUseHTMLString
    },
    // 消息持续时间
    duration: {
        type: Number,
        default: messageDefaults.duration
    },
    id: {
        type: String,
        default: messageDefaults.id
    },
    // 展示的消息内容
    message: {
        type: String,
        default: messageDefaults.message
    },
    // 偏移
    offset: {
        type: Boolean,
        default: messageDefaults.offset,
    },
    // 关闭回调方法
    onClose: {
        type: Function,
        default: messageDefaults.onClose
    }
})


export const messageEmits = {
    destroy: () => true
}
